﻿using DTcms.Common;
using System.Collections.Generic;
using System.Data;
using Model = DTcms.Model;
using BLL = DTcms.BLL;
using DTcms.Web.Mvc.UI;

namespace System.Web.Mvc.Html
{
    public static class HtmlHelperUsers
    {
        public static BaseController _base = new BaseController();

        /// <summary>
        /// OAuth平台列表
        /// </summary>
        /// <param name="top">显示条数</param>
        /// <param name="strwhere">查询条件</param>
        /// <returns>DataTable</returns>
        public static DataTable get_site_oauth_list(this HtmlHelper htmlHelper, int top, string strwhere)
        {
            return _base.get_site_oauth_list(top, strwhere);
        }

        /// <summary>
        /// 返回用户头像图片地址
        /// </summary>
        /// <param name="user_name">用户名</param>
        /// <returns>String</returns>
        public static string get_user_avatar(this HtmlHelper htmlHelper, string user_name)
        {
            return _base.get_user_avatar(user_name);
        }

        /// <summary>
        /// 返回用户头像图片地址
        /// </summary>
        /// <param name="user_name">用户ID</param>
        /// <returns>String</returns>
        public static string get_user_avatar(this HtmlHelper htmlHelper, int user_id)
        {
            return _base.get_user_avatar(user_id);
        }

        /// <summary>
        /// 返回用户昵称
        /// </summary>
        /// <param name="user_name">用户名</param>
        /// <returns>String</returns>
        public static string get_user_nick_name(this HtmlHelper htmlHelper, string user_name)
        {
            return _base.get_user_nick_name(user_name);
        }

        /// <summary>
        /// 返回用户昵称
        /// </summary>
        /// <param name="user_name">用户ID</param>
        /// <returns>String</returns>
        public static string get_user_nick_name(this HtmlHelper htmlHelper, int userid)
        {
            return _base.get_user_nick_name(userid);
        }

        /// <summary>
        /// 收货地址分页列表
        /// </summary>
        /// <param name="page_size">页面大小</param>
        /// <param name="page_index">当前页码</param>
        /// <param name="strwhere">查询条件</param>
        /// <param name="totalcount">总记录数</param>
        /// <returns>DateTable</returns>
        public static List<Model.user_addr_book> get_user_addr_book_list(this HtmlHelper htmlHelper, int page_size, int page_index, string strwhere, out int totalcount)
        {
            return _base.get_user_addr_book_list(page_size, page_index, strwhere, out totalcount);
        }

        /// <summary>
        /// 充值记录列表
        /// </summary>
        /// <param name="top">显示条数</param>
        /// <param name="strwhere">查询条件</param>
        /// <returns>DataTable</returns>
        public static List<Model.user_recharge> get_user_recharge_list(this HtmlHelper htmlHelper, int top, string strwhere)
        {
            return _base.get_user_recharge_list(top, strwhere);
        }

        /// <summary>
        /// 收货地址列表
        /// </summary>
        /// <param name="top">显示条数</param>
        /// <param name="strwhere">查询条件</param>
        /// <returns>DataTable</returns>
        public static List<Model.user_addr_book> get_user_addr_book_list(this HtmlHelper htmlHelper, int top, string strwhere)
        {
            return _base.get_user_addr_book_list(top, strwhere);
        }

        /// <summary>
        /// 判断是否登录
        /// </summary>
        /// <returns></returns>
        public static bool IsUserLogin(this HtmlHelper htmlHelper)
        {
            return _base.IsUserLogin();
        }

        /// <summary>
        /// 返回组别名称
        /// </summary>
        /// <param name="id">ID</param>
        /// <returns>String</returns>
        public static string get_groups_title(this HtmlHelper htmlHelper, int id)
        {
            return _base.get_groups_title(id);
        }

        /// <summary>
        /// 会员组别列表
        /// </summary>
        /// <param name="top">显示条数</param>
        /// <param name="strwhere">查询条件</param>
        /// <returns></returns>
        public static List<Model.user_groups> get_user_groups_list(this HtmlHelper htmlHelper, int top, string strwhere)
        {
            return _base.get_user_groups_list(top, strwhere);
        }

        /// <summary>
        /// 用户登录记录列表
        /// </summary>
        /// <param name="top">显示条数</param>
        /// <param name="strwhere">查询条件</param>
        /// <returns></returns>
        public static List<Model.user_login_log> get_user_log_list(this HtmlHelper htmlHelper, int top, string strwhere)
        {
            return _base.get_user_log_list(top, strwhere);
        }

        /// <summary>
        /// 判断当前用户是否绑定了第三方登录
        /// </summary>
        /// <param name="userId">用户ID</param>
        /// <param name="oauth">开放平台名称</param>
        /// <returns></returns>
        public static bool get_bool_user_oauth(this HtmlHelper htmlHelper, int userId, string oauth)
        {
            BLL.user_oauth bll = new BLL.user_oauth();
            int count = Utils.StrToInt(bll.GetCount("count(1)", string.Format("user_id={0} and oauth_name='{1}'", userId, oauth)));
            return count > 0;
        }

        /// <summary>
        /// 根据用户ID返回用户组别图片
        /// </summary>
        public static string UserGroImg(this HtmlHelper htmlHelper, int userId)
        {
            if (userId == 0)
            {
                return "";
            }
            return new BLL.users().UserGroImg(userId);
        }

        /// <summary>
        /// 返回用户qq联系方式
        /// </summary>
        /// <param name="user_name">用户ID</param>
        /// <returns>String</returns>
        public static string get_user_qq(this HtmlHelper htmlHelper, int user_id)
        {
            return _base.get_user_qq(user_id);
        }

        /// <summary>
        /// 积分明细分页列表
        /// </summary>
        /// <param name="page_size">页面大小</param>
        /// <param name="page_index">当前页码</param>
        /// <param name="strwhere">查询条件</param>
        /// <param name="totalcount">总记录数</param>
        /// <returns>DateTable</returns>
        public static List<Model.user_point_log> get_user_point_list(this HtmlHelper htmlHelper, int page_size, int page_index, string strwhere, out int totalcount)
        {
            return _base.get_user_point_list(page_size, page_index, strwhere, out totalcount);
        }

        /// <summary>
        /// 短信息分页列表
        /// </summary>
        /// <param name="page_size">页面大小</param>
        /// <param name="page_index">当前页码</param>
        /// <param name="strwhere">查询条件</param>
        /// <param name="totalcount">总记录数</param>
        /// <returns>DateTable</returns>
        public static List<Model.user_message> get_user_message_list(this HtmlHelper htmlHelper, int page_size, int page_index, string strwhere, out int totalcount)
        {
            return _base.get_user_message_list(page_size, page_index, strwhere, out totalcount);
        }

        /// <summary>
        /// 统计短信息数量
        /// </summary>
        /// <param name="strwhere">查询条件</param>
        /// <returns>Int</returns>
        public static int get_user_message_count(this HtmlHelper htmlHelper, string strwhere)
        {
            return _base.get_user_message_count(strwhere);
        }

        /// <summary>
        /// 余额明细分页列表
        /// </summary>
        /// <param name="page_size">页面大小</param>
        /// <param name="page_index">当前页码</param>
        /// <param name="strwhere">查询条件</param>
        /// <param name="totalcount">总记录数</param>
        /// <returns>DateTable</returns>
        public static List<Model.user_amount_log> get_user_amount_list(this HtmlHelper htmlHelper, int page_size, int page_index, string strwhere, out int totalcount)
        {
            return _base.get_user_amount_list(page_size, page_index, strwhere, out totalcount);
        }

        /// <summary>
        /// 用户邀请码列表
        /// </summary>
        /// <param name="top">显示条数</param>
        /// <param name="strwhere">查询条件</param>
        /// <returns></returns>
        public static List<Model.user_code> get_user_invite_list(this HtmlHelper htmlHelper, int top, string strwhere)
        {
            return _base.get_user_invite_list(top, strwhere);
        }

        /// <summary>
        /// 返回邀请码状态
        /// </summary>
        /// <param name="str_code">邀请码</param>
        /// <returns>bool</returns>
        public static bool get_invite_status(this HtmlHelper htmlHelper, string str_code)
        {
            return _base.get_invite_status( str_code);
        }

        /// <summary>
        /// 充值记录分页列表
        /// </summary>
        /// <param name="page_size">页面大小</param>
        /// <param name="page_index">当前页码</param>
        /// <param name="strwhere">查询条件</param>
        /// <param name="totalcount">总记录数</param>
        /// <returns>DateTable</returns>
        public static List<Model.user_recharge> get_user_recharge_list(this HtmlHelper htmlHelper, int page_size, int page_index, string strwhere, out int totalcount)
        {
            return _base.get_user_recharge_list(page_size, page_index, strwhere, out totalcount);
        }
    }
}
